package andy.demo.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class FileDemo {

    /**
     * @param args
     */
    public static void main(String[] args) {


        System.out.println("------");
        FileInputStream fis = null;
        try {
            fis = new FileInputStream("D:\\droidwork8\\andy-java-demo\\bin\\andy\\demo\\io\\from.txt");

            int r = 0;
            r = fis.read();

            System.out.println(r);
            r = fis.read();

            System.out.println(r);
            r = fis.read();

            System.out.println(r);

            byte[] buf = new byte[100];

            r = fis.read(buf);
            System.out.println(r);
            for (int i = 0; i < 4; i++) {
                // char b = (char)buf[i];
                int b = buf[i];
                System.out.println(b);
            }

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            try {
                fis.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }

}
